package com.thiswhyme.republish.rabbitmq.core.domain;

/**
 * @description: 消息来源类型
 * @author: thiswhyme
 * @date: 2021/7/27
 */
public enum MessageType {

    PRODUCE(1, "发送"),
    CONSUME(2, "消费");

    MessageType(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    private Integer value;
    private String desc;

    public Integer getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public static MessageType indexOf(int value) {
        for (MessageType item : MessageType.values()) {
            if (item.value == value) {
                return item;
            }
        }

        return null;
    }

    public static MessageType nameOf(String name) {
        for (MessageType item : MessageType.values()) {
            if (item.toString().equals(name)) {
                return item;
            }
        }
        return null;
    }

}
